<%@
	page pageEncoding="utf-8" session="false" contentType="text/html;charset=utf-8" import="
		java.util.List,java.util.Iterator,java.math.BigDecimal,java.util.Properties,
		java.util.ArrayList,java.util.HashMap,java.util.Map,java.util.StringTokenizer,
		org.json.simple.JSONObject,org.json.simple.JSONArray,com.innoace.mo.sql.*,
		com.innoace.mwp.MwpObject,com.innoace.mwp.MwpArray,com.innoace.mwp.MwpContext,
		com.innoace.mo.MoAction,com.innoace.mo.MoException,com.innoace.mo.MoFormat,
		org.apache.log4j.Logger,java.io.PrintWriter,
		com.innoace.mwp.*,java.util.*,java.text.*,org.apache.http.*,java.sql.*,org.json.simple.parser.*,com.innoace.mwp.MwpPlatform,com.innoace.mo.iss.*, com.innoace.mo.sql.vote.*
	"
%><%!
	Object cfg = null;// RESERVED
	public Logger log = Logger.getLogger("emp.jsp");
	Object app = null;
	
	public List<Vote> getResult(MwpContext ctx, Vote voteParam){
		List<Vote> voteRtn = null;
	
		try{			
			java.sql.Connection con = ctx.con;			
						
			voteRtn = ctx.mapper(VoteMapperOracle.class).getVoteResult(voteParam);
					
			con.close();
			
		}catch(Exception e){
			e.printStackTrace();
		}finally{
			return voteRtn;		
		}
	}
	
	public String nullToString(String targetStr){
		String returnStr;
		
		if(targetStr != null && !targetStr.equals("")){
			returnStr = targetStr;
		}else{
			returnStr = "-";
		}
		
		return returnStr;
	}
%>




<%
		MwpContext ctx = MwpContext.getContext();		
		com.innoace.mo.MoFormat fmt = com.innoace.mo.MoFormat.getFormat();
		try{
		
			ctx.init(request, response, out);
			com.innoace.mo.sql.UserMdn userMdn = null;
			org.json.simple.parser.JSONParser json = ctx.json;
			
			String sKey = request.getParameter("key") == null ? "" : request.getParameter("key");	

			Vote voteParam = new Vote();
			voteParam.voteSeq = sKey;

			List<Vote> rtnVoteList = getResult(ctx, voteParam);		
			
			System.out.println("List Size : "+rtnVoteList.size());	
			System.out.println("List pointTot : "+rtnVoteList.get(0).pointTot);	

%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, target-densitydpi=medium-dpi" />
<title>한국도로공사 모바일 투표</title>
<script type="text/javascript" src="http://m.ex.co.kr:8090/vote/js/jquery.min.js"></script>
<script type="text/javascript" src="http://m.ex.co.kr:8090/vote/js/highcharts.src.js"></script>
<script type="text/javascript" src="http://m.ex.co.kr:8090/vote/js/modules/exporting.js"></script>
<script src="http://m.ex.co.kr:8090/vote/js/chart.js" charset="utf-8"></script>
<script type="text/javascript">

			var chart;
			$(document).ready(function() {
				
				setTimeout("history.go(0);", 30000);

/**
CCChart				
			var chartdata = {
			
			  "config": {
			//    "title": "",
			//    "subTitle": "",
			    "type": "bar",
			    "barWidth": 48,
			    "colorSet":
			          ["#FF9114","#3CB000","#00A8A2","#0036C0","#C328FF","#FF34C0"],
			    "bgGradient": {
			            "direction":"vertical",
			            "from":"#ffffff",
			            "to":"#ffffff"
			          }
			  },
			
			  "data": [
			    ["투표항목",'영업소', '휴게소', '주유소', '안전순찰', '고객상담'],
			    ["총점",<%=rtnVoteList.get(0).pointTot%>,<%=rtnVoteList.get(1).pointTot%>,<%=rtnVoteList.get(2).pointTot%>,<%=rtnVoteList.get(3).pointTot%>,<%=rtnVoteList.get(4).pointTot%>]
			  ]
			};
			
			ccchart.init('canvasChart', chartdata);				
**/				
				
				
				var colors = Highcharts.getOptions().colors,
					categories = ['영업처', '도로처', '경남본부', '교통처', '도로사업처', '부안지사', '해외사업처', '교통처'],
//					name = '투표 항목',
					data = [{ 
							y: <%=rtnVoteList.get(0).pointConTot%>,
							color: colors[0],
							drilldown: {
								name: '영업처',
								categories: ['매우그렇다','그렇다','보통이다','그렇지않다','매우그렇지않다'],
								data: [5,3,4,5,3],
								color: colors[0]
							}
						}, {
						 	y: <%=rtnVoteList.get(1).pointConTot%>,
							color: colors[1],
							drilldown: {
								name: '도로처',
								categories: ['매우그렇다','그렇다','보통이다','그렇지않다','매우그렇지않다'],
								data: [5,3,4,5,3],
								color: colors[1]
							}
						}, {
							y: <%=rtnVoteList.get(2).pointConTot%>,
							color: colors[2],
							drilldown: {
								name: '경남본부',
								categories: ['매우그렇다','그렇다','보통이다','그렇지않다','매우그렇지않다'],
								data: [5,3,4,5,3],
								color: colors[2]
							}
						}, {
							y: <%=rtnVoteList.get(3).pointConTot%>,
							color: colors[3],
							drilldown: {
								name: '교통처',
								categories: ['매우그렇다','그렇다','보통이다','그렇지않다','매우그렇지않다'],
								data: [5,3,4,5,3],
								color: colors[3]
							}							
						}, {
							y: <%=rtnVoteList.get(4).pointConTot%>,
							color: colors[4],
							drilldown: {
								name: '도로사업처',
								categories: ['매우그렇다','그렇다','보통이다','그렇지않다','매우그렇지않다'],
								data: [5,3,4,5,3],
								color: colors[4]
							}
						}, {
							y: <%=rtnVoteList.get(5).pointConTot%>,
							color: colors[5],
							drilldown: {
								name: '부안지사',
								categories: ['매우그렇다','그렇다','보통이다','그렇지않다','매우그렇지않다'],
								data: [5,3,4,5,3],
								color: colors[5]
							}
						}, {
							y: <%=rtnVoteList.get(6).pointConTot%>,
							color: colors[6],
							drilldown: {
								name: '해외사업처',
								categories: ['매우그렇다','그렇다','보통이다','그렇지않다','매우그렇지않다'],
								data: [5,3,4,5,3],
								color: colors[6]
							}
						}, {
							y: <%=rtnVoteList.get(7).pointConTot%>,
							color: colors[7],
							drilldown: {
								name: '교통처',
								categories: ['매우그렇다','그렇다','보통이다','그렇지않다','매우그렇지않다'],
								data: [5,3,4,5,3],
								color: colors[7]
							}														
						}];

				
				function setChart(name, categories, data, color) {
					chart.xAxis[0].setCategories(categories);
					chart.series[0].remove();
					chart.addSeries({
						name: name,
						data: data,
						color: color || 'white'
					});
				}
				
				chart = new Highcharts.Chart({
					chart: {
						renderTo: 'container', 
						type: 'column'
					},
					title: {
//						text: '모바일 전자 투표'
//								style: {
//									fontWeight: 'bold'
//								}						
					},
					subtitle: {
//						text: '2012년 한국도로공사 경영대상(大賞) 모바일투표'
					},
					xAxis: {
						categories: categories					
					},
					yAxis: {
						title: {
							text: '투표현황'
						}
					},
					plotOptions: {
						column: {
							cursor: 'pointer',
							point: {
								events: {
									click: function() {
										var drilldown = this.drilldown;
										if (drilldown) { // drill down
											//setChart(drilldown.name, drilldown.categories, drilldown.data, drilldown.color);
										} else { // restore
											//setChart(name, categories, data);
										}
									}
								}
							},
							dataLabels: {
								enabled: true,
								color: colors[0],
								style: {
									fontWeight: 'bold'
								},
								formatter: function() {
									return this.y;
								}
							}					
						}
					},
					tooltip: {
						formatter: function() {
							var point = this.point,
								s = this.x +':<b>'+ this.y +'</b><br/>';
							return s;
						}
					},
					series: [{
						name: name,
						data: data,
						color: 'white'
					}],
					exporting: {
						enabled: false
					}
				});
				
			});
			
</script>
<style type="text/css"> 	
.title{
text-align:center; border:1px solid #8c8282; font-size:15px; font-weight:bold;}
.title_r{
text-align:right; border:1px solid #8c8282; font-size:15px; font-weight:bold;}

.content_c{
text-align:center; font-size:13px; font-weight:normal; padding:0; spacing:0;}


body[orient="portrait"]{min-height:200px;}
body[orient="landscape"]{min-height:200px;}
</style>
</head>
<BODY>
<form name="form" method="post">
<input type="hidden" name="key" value="<%=sKey%>"/>
</form>
<div>
<table style="width:100%; height:100px; margin:0 auto;">
	<tr>
		<td style="text-align:center; border:1px solid #8c8282; font-size:20px; color:#ffffff; font-weight:bold;background:#4b87c2">
		 2013년 한국도로공사 경영대상(大賞)
		</td>
	</tr>
</table>
<br>

<div id="container" style="width: 100%; height: 350px; margin: 0 auto;"></div>

<table style="width:100%; height:350px; margin:0 auto; margin-top:33px;">
<colgroup>
	<col style="WIDTH: auto" />
	<col style="WIDTH: 8%" />
	<col style="WIDTH: 8%" />
	<col style="WIDTH: 8%" />
	<col style="WIDTH: 8%" />
	<col style="WIDTH: 8%" />
	<col style="WIDTH: 8%" />
	<col style="WIDTH: 8%" />
</colgroup>	
	<tr style="height:30px; background:#479fc4;">
		<td class="title" rowspan="2">구분</td>
		<td class="title" colspan="2">임원(50%)</td>
		<td class="title" colspan="2">일반직원(50%)</td>
		<td class="title" colspan="2">총점</td>
		<td class="title" rowspan="2">순위</td>
	</tr>
	<tr style="height:30px; background:#479fc4;">
		<td class="title">획득점수</td>
		<td class="title">환산점수</td>						
		<td class="title">획득점수</td>
		<td class="title">환산점수</td>						
		<td class="title">획득점수</td>
		<td class="title">환산점수</td>										
	</tr>
<%
	for(int i=0; i<rtnVoteList.size(); i++){
		if(rtnVoteList.get(i).contentSeq != null && rtnVoteList.get(i).contentSeq.equals("999")){
%>
	<tr style="height:30px; background:#dadae0;">
		<td class="title">
			<%=rtnVoteList.get(i).contentTitle%>
		</td>
		<td class="title" colspan="2">
			<%=rtnVoteList.get(i).pointSpe%>&nbsp;&nbsp;&nbsp;
		</td>
		<td class="title" colspan="2">
			<%=rtnVoteList.get(i).pointEmp%>&nbsp;&nbsp;&nbsp;
		</td>
		<td class="title" colspan="2">
			<%=rtnVoteList.get(i).pointTot%>&nbsp;&nbsp;&nbsp;
		</td>		
		<td class="title">
			<%=nullToString(rtnVoteList.get(i).ranking)%>
		</td>										
	</tr>
<%			
		}else{
%>
	<tr style="height:30px; background:#dadae0;">
		<td class="title">
			<%=rtnVoteList.get(i).contentTitle%>
			<div class="content_c">(<%=rtnVoteList.get(i).content%>)</div>
		</td>
		<td class="title_r">
			<%=rtnVoteList.get(i).pointSpe%>&nbsp;&nbsp;&nbsp;
		</td>		
		<td class="title_r">
			<%=rtnVoteList.get(i).pointConSpe%>&nbsp;&nbsp;&nbsp;
		</td>
		<td class="title_r">
			<%=rtnVoteList.get(i).pointEmp%>&nbsp;&nbsp;&nbsp;
		</td>		
		<td class="title_r">
			<%=rtnVoteList.get(i).pointConEmp%>&nbsp;&nbsp;&nbsp;
		</td>
		<td class="title_r">
			<%=rtnVoteList.get(i).pointTot%>&nbsp;&nbsp;&nbsp;
		</td>		
		<td class="title_r">
			<%=rtnVoteList.get(i).pointConTot%>&nbsp;&nbsp;&nbsp;
		</td>
		<td class="title">
			<%=nullToString(rtnVoteList.get(i).ranking)%>
		</td>										
	</tr>
<%	
		}	
	}
%>
</table>			
</div>
</body>
</html>
<%
		}finally{
			ctx.destroy();
		}				

%>
